const fs = require('fs')
/**
 * 读取router文件夹下的文件，动态注册路由对象
 *
 * @param {*} app
 */
function registerRoutes (app) {
  // fs读取本文件夹文件
  const files = fs.readdirSync(__dirname)
  for (const file of files) {
    if (!file.endsWith('.route.js')) continue
    const router = require(`./${file}`)
    app.use(router.routes())
    app.use(router.allowedMethods())
  }
}
module.exports = registerRoutes